
const bindActionCreator = (action,dispatch)=>{
  return function(){
    dispatch(action.apply(this, arguments))
  }
}
export default (actions, dispatch)=>{
  if(typeof actions === 'function'){
    return bindActionCreator(actions, dispatch)
  }else{
    if (typeof actions !== 'object' || actions === null) {
      throw new Error('您传入内容不合法')
    }
    let keys = Object.keys(actions)
    let nextActions = {}
    for(let item of keys){
      nextActions[item] =  bindActionCreator(actions[item], dispatch)
    }
    return nextActions
  }
}